package com.cls.business.mapper;

import com.cls.business.entity.TopicSelect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cls.business.vo.TopicSelectVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 征集选题 Mapper
 *
 * @author wmm
 * @date 2020-11-12 09:22:38
 */
@Repository
public interface TopicSelectMapper extends BaseMapper<TopicSelect> {


    List<TopicSelectVO> selectTopicSelectsForClient(@Param("topicSelect") TopicSelectVO topicSelect);

    TopicSelectVO selectDetailForClient(@Param("topicSelectId") Long topicSelectId);


    @Select("select GROUP_CONCAT(dict.name) as subjectTypeNames, dict.name,topic.*,CONCAT_WS ('/',unit_name,user_name," +
            "(select name from sys_dict d where d.code=position) ,\n" +
            "profession_code" +
            ",phone) excelConcatWs\n" +
            "from biz_topic_select topic\n" +
            "inner join \n" +
            "sys_dict dict\n" +
            "where \n" +
            "FIND_IN_SET(dict.code,topic.subject_type_codes)\n" +
            "and topic.year=#{year} and is_submit=1 \n"+
            "GROUP BY topic.select_id")
    List<TopicSelectVO> selectList4Export(String year);
}
